Why is the .replace() method not working